﻿//  --------------------------------
//  Copyright (c) AW Systems, Inc. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://www.codeplex.com/SLAM/license
//  ---------------------------------

using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using AWS.SLAM;
using AWS.SLAM.Activation;
using AWS.SLAM.Configuration;
using AWS.SLAM.Data;
using AWS.SLAM.Events;
using AWS.SLAM.Logging;
using AWS.SLAM.SharePoint;
using StructureMap;
using StructureMap.Attributes;
using StructureMap.Configuration.DSL;
using StructureMap.Pipeline;


namespace AWS.SLAM.StructureMap
{
    public class SLAMRegistry : Registry
    {
        protected override void configure()
        {
            if (ConfigurationManager.AppSettings["AWS.SLAM.ConfigurationManager.Config"] != null)
            {
                ForRequestedType<IConfigurationManager>().CacheBy(InstanceScope.Singleton).TheDefault.Is.OfConcreteType<XmlConfigurationManager>()
                    .WithCtorArg("configurationLocation").EqualToAppSetting("AWS.SLAM.ConfigurationManager.Config", "");
            }
            else
            {
                ForRequestedType<IConfigurationManager>().CacheBy(InstanceScope.Singleton).TheDefault.Is.IsThis(new XmlConfigurationManager());
            }
            ForRequestedType<IDataServices>()
                .TheDefaultIsConcreteType<SqlDataServices>();

            ForRequestedType<ILogger>()
                .TheDefaultIsConcreteType<SqlLogger>().CacheBy(InstanceScope.Singleton);

            ForRequestedType<IDataSynchronizer>()
                .TheDefaultIsConcreteType<DataSynchronizer>();

            ForRequestedType<IDataSynchronizeTypeProcessor>()
               .TheDefaultIsConcreteType<SqlDataSynchronizeTypeProcessor>();

            ForRequestedType<IActivator>()
                .TheDefaultIsConcreteType<Activator>();
        }
    }
}
